package com.hxk.exception;

import java.util.Properties;

import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
/**
 * 全局异常类使用配置SimpleMappingExceptionResolver
 * @author Cactus
 */
import org.springframework.web.servlet.handler.SimpleMappingExceptionResolver;
@Configuration
public class GlobalException2 {

	/**
	 * 注册异常处理类SimpleMappingExceptionResolver
	 * @return
	 */
	@Bean
	public SimpleMappingExceptionResolver getSimpleMappingExceptionResolver() {
		SimpleMappingExceptionResolver bean = new SimpleMappingExceptionResolver();
		Properties mappings = new Properties();
		/**
		* 参数一：异常的类型，注意必须是异常类型的全名
		* 参数二：视图名称
		*/
		mappings.setProperty("java.lang.ArrayIndexOutOfBoundsException", "error3");
		mappings.setProperty("java.lang.NumberFormatException", "error4");
		bean.setExceptionMappings(mappings);
		return bean;
	}
}
